Skip to content

Refactor duplicated code: extract reusable partials and helpers - #241

Draft
gurusabarish with Copilot wants to merge 3 commits into
masterfrom
copilot/refactor-duplicated-code
Draft

Refactor duplicated code: extract reusable partials and helpers#241
gurusabarish with Copilot wants to merge 3 commits into
masterfrom
copilot/refactor-duplicated-code

Conversation

Copilot AI commented Nov 2, 2025

Copy link
Copy Markdown
Contributor

Eliminated code duplication across template files by extracting repeated patterns into reusable partials.

Changes

  • Social network icons - Extracted 5 SVG definitions (GitHub, LinkedIn, Twitter, Instagram, Facebook) from inline markup into layouts/partials/socialIcons/

    • Reduced socialNetwork.html from 95 to 37 lines
  • Card components - Created reusable partials for repeated card markup:

    • layouts/partials/cards/project.html - Used in 3 locations (projects section, projects list, content pages)
    • layouts/partials/cards/blogPost.html - Used in 2 locations (blog list, recent posts footer)
  • Achievement cards - Collapsed URL/non-URL variants into single conditional structure

    • Reduced from 38 to 21 lines
  • ID sanitization - Extracted replaceRE regex pattern into layouts/partials/helpers/sanitizeId.html

    • Removed 5 duplicate instances in experience section

Example

Before:

<div class="card my-3 h-100">
  <div class="card-head">
    <img class="card-img-top" src="{{ .image }}" alt="{{ .title }}">
  </div>
  <!-- 30+ lines of card markup -->
</div>

After:

{{- partial "cards/project.html" . -}}

Impact: Net -32 lines, improved consistency across theme.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • publish.twitter.com

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Find and refactor duplicated code


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 2, 2025 06:12
…ation

Co-authored-by: gurusabarish <53465361+gurusabarish@users.noreply.github.com>
Co-authored-by: gurusabarish <53465361+gurusabarish@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor duplicated code for better maintainability Refactor duplicated code: extract reusable partials and helpers Nov 2, 2025
Copilot AI requested a review from gurusabarish November 2, 2025 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants